package com.xinjiang.electricpower.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.system.api.domain.SysStaff;
import com.xinjiang.electricpower.domain.SysOrg;
import com.xinjiang.electricpower.domain.vo.OrgConfigVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author feizhao
 * @date 2022/12/6
 * @apiNote 供电所Mapper接口类
 */
public interface SysOrgMapper extends BaseMapper<SysOrg> {


    @Select(" select soi.id org_info_id," +
            "so.org_name," +
            "so.org_no," +
            "omi.employees, " +
            "omi.users, " +
            "omi.manage_common_variable, " +
            "omi.mange_specific_variable, " +
            "concat(soi.longtitude,',',soi.latitude) longtitudeAndLatitude " +
            "from sys_org so " +
            "left join sys_org_info soi on so.org_no = soi.org_no " +
            "left join org_manager_info omi on omi.org_no = soi.org_no " +
            " ${ew.customSqlSegment} ")
    IPage<OrgConfigVO> selectSysOrgInfoList(IPage<OrgConfigVO> page, @Param("ew") QueryWrapper<OrgConfigVO> wrapper);

    /** 根据当前账号获取用户对应系统的账号 */
    @Select("select mapping_code from sys_mapper_user where user_name = #{userName} and integsys_code = #{integsysCode}")
    String getMappingCodeByUserNameAndIntegsysCode(@Param("userName") String userName,
                                                   @Param("integsysCode") String integsysCode);
    /** 查询当前部门的所有用户 */
    List<SysStaff> getUserByDeptId(@Param("deptId") String deptId);
}
